﻿
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using System.Xml.Serialization;
using WebSite.App_Data;

namespace WebSite.App_Code
{    
    /// <summary>
    /// 项目预算信息
    /// </summary>
    [Serializable]
    public class UtilityEntity
    {
        public UtilityEntity() 
        {
        }

        public static decimal? CDecimal(Object x) {

            try {
                if (x == null)
                    return null;
                else
                    return Convert.ToDecimal(x);
            }
            catch (Exception) { return null; }
        }

        public static DateTime? CDateTime(Object x)
        {

            try
            {
                if (x == null)
                    return null;
                else
                    return Convert.ToDateTime(x);
            }
            catch (Exception) { return null; }
        }
    }

    public class MultiButtonAttribute : ActionNameSelectorAttribute
    {
        public string Name { get; set; }
        public MultiButtonAttribute(string name)
        {
            this.Name = name;
        }
        public override bool IsValidName(ControllerContext controllerContext,
            string actionName, System.Reflection.MethodInfo methodInfo)
        {
            if (string.IsNullOrEmpty(this.Name))
            {
                return false;
            }
            return controllerContext.HttpContext.Request.Form.AllKeys.Contains(this.Name);
        }
    }
}
